home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
elan1v5.arc
/
DEMO.ARC
/
PRIMES.E
< prev
next >
Wrap
Text File
|
1989-03-10
|
1KB
|
64 lines
PROC put (INT CONST a):
IF get column + int length > xsize
THEN line
FI;
put (text (a, int length))
ENDPROC put;
primtab:
LET limit = 1000;
calculate int length;
start table;
WHILE m < limit
REP
try if m is prime;
take next m
ENDREP;
how long.
calculate int length:
INT VAR lgth :: 1;
WHILE 10 ** lgth < limit
REP lgth INCR 1
ENDREP;
INT CONST int length :: lgth + 2.
start table:
put ("Table of prime numbers <");
put (limit);
line (2);
put (2);
INT VAR m :: 3.
try if m is prime:
INT VAR k :: 3;
WHILE m may be divisible
REP
try k as divisor;
increase k
ENDREP;
put (m).
m may be divisible:
k * k <= m.
try k as divisor:
IF m MOD k = 0
THEN
LEAVE try if m is prime
FI.
increase k:
k INCR 2.
take next m:
m INCR 2.
how long:
line (2);
put ("Time= ");
put (exectime);
put (" sec.").
⇦